package com.supostacks.application.application.impl;

import com.alibaba.fastjson.JSONObject;
import com.supostacks.application.application.ICategoryApplication;
import com.supostacks.domain.service.ICategoryService;
import com.supostacks.domain.vo.BaseVo;
import com.supostacks.domain.vo.CategoryVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Service
public class CategoryApplicationImpl implements ICategoryApplication {
    @Resource
    private ICategoryService categoryService;

    @Override
    public String insert(JSONObject data) {
        CategoryVo categoryVo = JSONObject.toJavaObject(data, CategoryVo.class);
        return categoryService.insert(categoryVo);
    }

    @Override
    public void deleteById(String id) {
        categoryService.deleteById(id);
    }

    @Override
    public String updateById(JSONObject data) {
        CategoryVo categoryVo = JSONObject.toJavaObject(data, CategoryVo.class);
        return categoryService.updateById(categoryVo);
    }

    @Override
    public CategoryVo selectById(String id) {
        return categoryService.selectById(id);
    }


    @Override
    public List<BaseVo> selectList(JSONObject options) {
        List<CategoryVo> categoryVos = categoryService.selectList(options);
        return new ArrayList<>(categoryVos);
    }

    @Override
    public JSONObject selectByPage(JSONObject options, int pageNo, int pageSize) {
        return categoryService.selectByPage(options, pageNo, pageSize);
    }

    @Override
    public List<BaseVo> search(JSONObject option) {
        return Collections.emptyList();
    }

}
